package pers.vic.upload.login.dao;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import pers.vic.upload.login.model.User;

import javax.annotation.Resource;

/**
 * 描述:login  dao
 * @author Vic.xu
 * @date 2022-07-06 9:26
 */
@Repository
public class LoginDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    public User findUser(String username){
        String sql = "SELECT a.id, a.ENABLE_FLAG AS enabled, a.USER_NAME username, a.NAME , a.PASSWORD  " +
                ", b.fk_organization_id AS fkOrganizationId, b.fk_org_company_id  as fkOrgCompanyId " +
                "FROM t_stl_S_user a left join  t_stl_s_identity  b on a.identity_default = b.id " +
                "WHERE a.USER_NAME = ?";

        return jdbcTemplate.queryForObject(
                sql, new BeanPropertyRowMapper<User>(User.class), username);

    }


}
